﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kaiser.Modules.Hiner.Repositories;
using Kaiser.Modules.Hiner.Models.Consignee;
using Kaiser.Models;

namespace Kaiser.Repositories.iBatis.HINER
{
    public class ConsigneeRepositorie : IConsigneeRepositorie
    {

        private IBatisHepler IBatisHepler = null;
        public ConsigneeRepositorie()
        {
            IBatisHepler = new BatisHepler("SQLMap.Hinner.config");
        }

        public void Insert(Modules.Hiner.Models.Consignee.ConsigneeBase consignee)
        {
            var result = IBatisHepler.ExcuteInsert("InsertConsignee", consignee);
        }

        public void Update(Modules.Hiner.Models.Consignee.ConsigneeBase consignee)
        {
            var result = IBatisHepler.ExcuteUpdate("UpdateConsignee", consignee);
        }


        public int Delete(object primaryId)
        {
            var result = IBatisHepler.ExcuteDelete("DeleteConsignee", primaryId);
            return result;
        }

        public Modules.Hiner.Models.Consignee.ConsigneeBase Get(object primaryId)
        {
            ConsigneeBase result = IBatisHepler.ExcuteSelectObj("GetConsignee", primaryId) as ConsigneeBase;
            return result;
        }

        public Models.DataGrid<Modules.Hiner.Models.Consignee.ConsigneeBase> SearchConsignee(Modules.Hiner.Models.Consignee.SearchModels.ConsigneeSearch search, Models.PagingInfo pageinfo)
        {
            var result = new DataGrid<ConsigneeBase>();

            int totalCount = 0;

            result.TableResult = IBatisHepler.ExcuteSelect("SearchConsignee", search, pageinfo.Size, pageinfo.Index + 1, out totalCount);

            result.total = totalCount;

            return result;
        }


        public int DeleteList(IList<string> ids)
        {
            throw new NotImplementedException();
        }
    }
}
